using Microsoft.Practices.EnterpriseLibrary.Logging;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Text;

namespace Sandia.MVCFramework.Test
{    
    [TestFixture]
    public class NUnitTraceListenerTests 
    {
        [Test]
        public void NUnitTraceListenerTest()
        {
            // Generate a log entry
            LogEntry logEntry = new LogEntry();
            logEntry.Message = "Not really an error - just testing NUnitTestListener";
            logEntry.Priority = 100;
            logEntry.Categories.Add("Error");
            Logger.Write(logEntry);

            Assert.IsTrue(NUnitTraceListener.Called);
        }

        /// <summary>
        /// Reset error logging flag before running test
        /// </summary>
        [SetUp]
        public void SetupTestFixture()
        {
            // Reset error flag
            NUnitTraceListener.Called = false;
        }

        /// <summary>
        /// Fail if any errors were logged during the test
        /// </summary>
        /// <remarks>This is the code to put in all other tests to catch the errors
        /// (commented out here so that this test will pass)</remarks>
        [TearDown]
        public void TeardownTestFixture()
        {
            // Make sure no errors were logged
//            Assert.IsFalse(NUnitTraceListener.Called, "Error was caught during test - check Console.Error output for details");
        }
    }
}
